//
//  AchievementVC.m
//  NJUSTHelper
//
//  Created by 郑越辉 on 2017/9/14.
//  Copyright © 2017年 njust. All rights reserved.
//

#import "AchievementVC.h"
#import <ASIHTTPRequest.h>
#import <ASIFormDataRequest.h>
#import <AFNetworking.h>
@interface AchievementVC () <UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webview;
@property (nonatomic, strong) NSString *urlStr;
@property (nonatomic, strong) NSString *innerStr;

@property (nonatomic, strong) NSURL *url;
@end

@implementation AchievementVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"考试与成绩";
    [SVProgressHUD show];
//    ASIFormDataRequest *req = [[ASIFormDataRequest alloc]initWithURL:[NSURL URLWithString:@"http://njusthelper.duapp.com/njust0909/GPALogin.php"]];
//    NSString * body = [[NSString alloc]init];
//    [body stringByAppendingString:@"------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"stuid\"\r\n\r\n914106840617\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"pwd\"\r\n\r\n123456\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"];
//
//    
//    [req setPostBody:[body cStringUsingEncoding:NSASCIIStringEncoding]];
//    
//    [req startSynchronous];
    
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"image/jpeg", nil];
//    
//    NSMutableDictionary *para = [NSMutableDictionary dictionary];
//    NSString *url;
//    url = @"http://njusthelper.duapp.com/njust0909/GPALogin.php";
//    [para setObject:@"914106840617" forKey:@"stuid"];
//    [para setObject:@"123456"  forKey:@"pwd"];
//    
    
//    NSString *str = [req responseString];
//    NSLog(@"%@", str);
//    [SVProgressHUD dismiss];

    self.webview = [[UIWebView alloc]initWithFrame:self.view.bounds];
    self.webview.scrollView.scrollEnabled = YES;
//    [self.webview setKeyboardDisplayRequiresUserAction:NO];
    [self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://njusthelper.duapp.com/njust0909/index.html"]]];
    self.webview.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.webview];
    
    
    [SVProgressHUD dismiss];
    
    
    
    
}


-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    
//
//        NSString *place = [NSString stringWithFormat:@"window.placeHTMLToView('%@')",[NSString nullString:self.innerStr RepleseWith:@""]];
//        [webView stringByEvaluatingJavaScriptFromString:place];
//        
//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//            
//            CGFloat webViewHeight= [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"]floatValue];
//            CGRect newFrame = webView.frame;
//            newFrame.size.height= webViewHeight;
//            webView.frame= newFrame;
//            
//                        //            self.footview.sd_layout
//            //            .topSpaceToView(self.webview, 10)
//            //            .topEqualToView(self.scrollview)
//            //            .rightEqualToView(self.scrollview)
//            //            .heightIs(96);
//        });
//    
}
@end
